{template 'web/common/header'}

<body>
    <style>
        * {
            -webkit-box-sizing: initial;
            -moz-box-sizing: initial;
            box-sizing: initial;
        }

        .layui-upload-img {
            width: 92px;
            height: 92px;
            margin: 0 10px 10px 0;
        }

        .layui-input-required {
            color: #ff0000;
            font-weight: 800;
        }

        .layui-anim-upbit .switch:before {
            background: none !important;
        }

        .layui-anim-upbit .switch:after {
            background: none !important;
            height: inherit;
            width: inherit;
            border: 0;
            position: inherit;
            top: -4px;
        }

        .layui-treeSelect .ztree li span.button.switch {
            top: -6px;
        }
    </style>
    <form class="layui-form" action="" lay-filter="component-form-group">
        <div class="layui-fluid">
            <div class="layui-card">
                <div class="layui-card-header">基本信息</div>
                <div class="layui-card-body" style="padding: 15px;">

                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="layui-input-required">*</span>客户名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" lay-verify="required" placeholder="请输入客户名称" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">客户编号</label>
                        <div class="layui-input-block">
                            <input type="text" name="number" placeholder="请输入客户编号" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="layui-input-required">*</span>客户分类</label>
                        <div class="layui-input-block">
                            <input type="text" name="category_id" id="category_tree" lay-filter="tree" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class=" layui-form-label">联系方式</label>
                        <div class="layui-input-block">
                            <input type="text" name="link" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class=" layui-form-label">客户等级</label>
                        <div class="layui-input-block">
                            <input type="text" name="leveid" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class=" layui-form-label">地区</label>
                        <div class="layui-input-block">
                            <input type="text" name="area" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class=" layui-form-label">物流编码</label>
                        <div class="layui-input-block">
                            <input type="text" name="logistics_code" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class=" layui-form-label">默认仓库</label>
                        <div class="layui-input-block">
                            <input type="text" name="default_storage" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class=" layui-form-label">业务员</label>
                        <div class="layui-input-block">
                            <input type="text" name="saleman" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class=" layui-form-label">邮编</label>
                        <div class="layui-input-block">
                            <input type="text" name="zipcode" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class=" layui-form-label">传真</label>
                        <div class="layui-input-block">
                            <input type="text" name="fax" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class=" layui-form-label">详细地址</label>
                        <div class="layui-input-block">
                            <input type="text" name="address" class="layui-input">
                        </div>
                    </div>

                </div>
            </div>
        </div>


        <div class="layui-fluid">
            <div class="layui-card">
                <div class="layui-card-header">其他设置</div>
                <div class="layui-card-body" style="padding: 15px;">
                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">备注</label>
                        <div class="layui-input-block">
                            <textarea placeholder="请输入内容" class="layui-textarea" name="remark"></textarea>
                        </div>
                    </div>

                </div>
            </div>
        </div>
        <div class="layui-form-item layui-layout-admin">
            <div class="layui-input-block">
                <div class="layui-footer" style="left: 0;">
                    <button class="layui-btn" lay-submit="" lay-filter="component-form">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </div>
    </form>
    <script src="../addons/xn_erp/images/layuiadmin/layui/layui.js"></script>
    <script>
        //Demo
        layui.config({
            base: '../addons/xn_erp/images/layuiadmin/layui/extend/'
        }).use(['form', 'upload', 'treeSelect'], function () {
            var form = layui.form, upload = layui.upload, $ = layui.$, treeSelect = layui.treeSelect;

            treeSelect.render({
                // 选择器
                elem: '#category_tree',
                // 数据
                data: 'http://3.lhbbk.com/web/index.php?c=site&a=entry&do=set&m=xn_erp&op=category&type=contact&api=tree',
                // 异步加载方式：get/post，默认get
                type: 'get',
                // 占位符
                placeholder: '请选择分类',
                // 是否开启搜索功能：true/false，默认false
                search: true,
                // 点击回调
                click: function (d) {
                    console.log(d);
                },
                // 加载完成后的回调函数
                success: function (d) {
                    console.log(d);
                    //                选中节点，根据id筛选
                    //                treeSelect.checkNode('tree', 3);

                    //                获取zTree对象，可以调用zTree方法
                    //                var treeObj = treeSelect.zTree('tree');
                    //                console.log(treeObj);

                    //                刷新树结构
                    //                treeSelect.refresh();
                }
            });


            //监听提交
            form.on('submit(component-form)', function (data) {
                var url = "{$url}&op=add&api=add";
                // console.log(url)
                console.log(data.field);
                $.ajax({
                    // async: false,
                    type: "POST",
                    url: url,
                    // contentType: "application/x-www-form-urlencoded; charset=utf-8",
                    data: data.field,
                    // dataType: "josn",
                    success: function (result) {
                        layer.alert(result);
                    },
                    error: function (result) {
                        console.log(result);
                    }
                })
                // layer.open({type:1,content:JSON.stringify(data.field)});
                return false;
            });


        });


    </script>
</body>

</html>